import {useLocation, useParams, useSearchParams} from "react-router-dom";
import {Button} from "antd";
import {confirmQrCodeLogin} from "@/api/login.ts";
import {globalMessageApi} from "@/components/OpComponent/Message";
import {useCallback} from "react";


export default function (){

    const [searchParams] = useSearchParams();
    const qrCodeId = searchParams.get('qrCodeId');

    const handleLogin = useCallback(() => {
        globalMessageApi.success('qrCodeId '+  qrCodeId)
        if(!qrCodeId) return
        confirmQrCodeLogin(qrCodeId, 'admin', '123456').then(res => {
            globalMessageApi.success('登录成功' + res)
            console.log(res)
        })
    }, [qrCodeId])


    return <div>
        {/*用户名*/}
        <Button onClick={handleLogin}>登录</Button>
    </div>
}
